package edu.ynu.se.xiecheng.achitectureclass.entity;

import edu.ynu.se.xiecheng.achitectureclass.common.entity.LogicEntity;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.Where;

import javax.persistence.*;
import java.util.Date;

@Getter
@Setter
@MappedSuperclass
@Where(clause = "is_deleted = 0")
public abstract class DeviceDataBase extends LogicEntity {
    @Column
    private Date timestamp;
    @Column
    private Integer dataType;
    @Column
    private String name;
    @Column
    private Integer value;

    @Column
    private String boxId;

    @Column
    private Integer status;
    @Column
    private Integer connState;
    @Column
    private Date connStateTimestamp;

    @Column(name = "greenhouse_id", nullable = false)

    private Long greenhouseId;

    @ManyToOne(fetch = FetchType.LAZY)

    @JoinColumn(name = "greenhouse_id", insertable = false, updatable = false)

    private Greenhouse greenhouse;


    @Column(name = "device_id", nullable = false)

    private Long deviceId;

    @ManyToOne(fetch = FetchType.LAZY)

    @JoinColumn(name = "device_id", insertable = false, updatable = false)

    private Device device;
}